<script src="<?php echo base_url()?>/public/assets/js/laydate/laydate.js" type="text/javascript"></script>
<div class="row">
	<div class="col-sm-12">
	    <div>
    		<a href="/nursery/coursepackage?per_page=<?php if(!empty($_REQUEST['per_page']))echo $_REQUEST['per_page']?>" class="btn btn-info_01 float_right btn_search">返回</a>
    	</div>
		<div class="space"></div>
        <form action="/nursery/coursepackage/update" method="post" onsubmit=" return yanzheng()">
		<input type="hidden" value="update" name="form_submit" />
		<input type="hidden" value="<?php echo $course_package_info['id']?>" name="id" />
		<table width="100%" class="table table-striped table-bordered table-hover" widtd="100%">
			<tr>
			  <td height="30" widtd="15%">课程分类：</td>
			  <td height="30" align="left" widtd="85%">
			  <select name="course_cate_id" onchange="getcourselist(value);">
			  	<?php foreach ($course_cate_list as $val){?>
			  	<option value="<?php echo $val['id']?>"><?php echo $val['title']?></option>
			  	<?php }?>
			  </select>			  </td>
		  </tr>
		  <tr>
			  <td height="30" widtd="15%">课程列表：</td>
			  <td height="30" align="left" widtd="85%">
			  <select name="course_list_id">
			  	
			  </select>
			  </td>
		  </tr>
			<tr>
			    <td width="15%" height="30" widtd="15%">名称：</td>
				<td width="85%" height="30" align="left" widtd="85%"><input type="text" value="<?php echo $course_package_info['title']?>" name="title"/></td>
			</tr>
			<tr>
			  <td height="30">图标：</td>
			  <td height="30" align="left">
			  <img src="<?php echo $course_package_info['logo']?>" width='100px' />			  </td>
		  </tr>
			<tr>
			  <td height="30">课时：</td>
			  <td height="30" align="left"><input type="text" value="<?php echo $course_package_info['hours']?>" name="hours" onkeyup='this.value=this.value.replace(/\D/gi,"")'/></td>
		  </tr>
			<tr>
			  <td height="30">原价：</td>
			  <td height="30" align="left"><input type="text" value="<?php echo $course_package_info['cost_price']?>" name="cost_price" onkeyup='this.value=this.value.replace(/\D/gi,"")'/></td>
		  </tr>
			<tr>
			  <td height="30">售价：</td>
			  <td height="30" align="left"><input type="text" value="<?php echo $course_package_info['sale_price']?>" name="sale_price" onkeyup='this.value=this.value.replace(/\D/gi,"")'/></td>
		  </tr>
			<tr>
			  <td height="30">是否体验包：</td>
			  <td height="30" align="left">
			  <select name="type">
			  	<option value="0">是</option>
				<option value="1">否</option>
			  </select>
			  </td>
		  </tr>
			<tr>
			  <td height="30">简介：</td>
			  <td height="30" align="left">
			  <textarea name="intro" style="width:400px"><?php echo $course_package_info['intro']?></textarea></td>
		  </tr>
			<tr>
			  <td height="30" colspan="2"><div align="center"><input type="submit" value="提交" /></div></td>
		  </tr>
	  </table>
	  </form>
	</div>
</div>
<script>
$("[name='course_cate_id']").val(<?php echo $course_list_info['course_cate_id']?>);
$("[name='type']").val(<?php echo $course_package_info['type']?>);
getcourselist(<?php echo $course_list_info['course_cate_id']?>);
function yanzheng(){ 
	if(!$("[name='title']").val()){ 
	    alert('请输入名称！'); 
	    return false; 
	}
	if(!$("[name='hours']").val()){ 
	    alert('请输入课时！'); 
	    return false; 
	}
	if(!$("[name='cost_price']").val()){ 
	    alert('请输入原价！'); 
	    return false; 
	}
	if(!$("[name='sale_price']").val()){ 
	    alert('请输入售价！'); 
	    return false; 
	}
	if(!$("[name='intro']").val()){ 
	    alert('请输入简介！'); 
	    return false; 
	}
	if(!confirm('确定要修改吗？')){
		return false;
	}
}
function getcourselist(id){
		$.ajax({
    	    type : "get", 
    	    async:false, 
    	    url : "/nursery/coursepackage/getcourselist?course_cate_id="+id, 
    	    dataType : "json", 
    	    success : function(data){
    		    if(data['code'] == 10){
    		    	var content = '';
    		    	var list = data['list'];
    		    	for(var i=0;i<list.length;i++){
    		    		content+= '<option value="'+list[i]['id']+'">'+list[i]['title']+'</option>';
    			    }
    			    $("[name='course_list_id']").html(content);
    			}else{
    				alert(data['msg']);
    			}
    	    }, 
    	    error:function(){
    	        alert('fail'); 
    	    } 
	});
}
</script>
<!--content-->